
package tests.laurens.cajo_remote_stub;

import gnu.cajo.invoke.Remote;
import gnu.cajo.utils.extra.TransparentItemProxy;

import java.util.ArrayList;

import combat.dudes.protocol.interfaces.TrackInt;


/**
 * @author Laurens Andriessen
 * @version 1.0
 */
public class TestClient {
	public static void main(String[] args) throws Exception {
		CakeInt cake = (CakeInt) TransparentItemProxy.getItem("//localhost:28000/Cookbook", new Class[] { CakeInt.class });
		ArrayList<Remote> ingredients = cake.getCakeIngredients();
		for(int i = 0; i < ingredients.size(); i++) {
			// System.out.println("Remote.invoke(ingredients.get(i), \"getFlavour\", null): " + Remote.invoke(ingredients.get(i), "getFlavour", null));

			CakeIngredientInt ing = (CakeIngredientInt) TransparentItemProxy.getItem(ingredients.get(i), new Class[] { CakeIngredientInt.class });
			System.out.println("ing:" + ing.getFlavour());
			if(i == 2) ing.setFlavour("Yum:]!");

			ArrayList<Remote> subflavourAsTrack = ing.getSubIngredients();
			ArrayList<TrackInt> test = new ArrayList<TrackInt>();
			for(Object rem : subflavourAsTrack)
				test.add((TrackInt) TransparentItemProxy.getItem(rem, new Class[] { TrackInt.class }));
			System.out.println(test.size());
		}
	}
}
